import wepy from 'wepy'

export default class  extends wepy.mixin {
    data = {
        cates:[],
        activeKey:0,
        // 二类分类数据
        secondCate:[]
    }

    config = {
    }

    methods = {
        // 监听侧边导航切换事件
        sidebarChange(e){
            this.secondCate=this.cates[e.detail].children
            
        }
    }
    // 获取分类数据
    async getCatesList(){
       const {data:res}= await wepy.get('/categories')
       if(res.meta.status!=200) return wepy.baseToast()
        this.cates=res.message
        this.secondCate=res.message[0].children
        this.$apply()
    }
    onLoad(){
        this.getCatesList()
    }
}